package org.millioncall.yueyoga.admin.model;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.millioncall.yueyoga.common.utils.JoinUtils;

/**
 * 前端班级显示实体
 * 
 * @author zangjinyu
 * 
 */
public class ClassRecord {
	private Integer id;// 班级编号
	private String name;// 班级名称
	private String type;// 班级类型
	private String state;// 班级状态
	private String officer;// 班级负责人
	private List<String> products; // 班级产品
	private String startTime;
	private String endTime;
	private List<ScheduleRecord> schedules;// 班级课程情况
	private Map<String, String> cachePlaces;
	private Map<String, String> cacheMainTeachers;
	private Map<String, String> cacheAssistants;

	public ClassRecord() {
		this.cachePlaces = new HashMap<String, String>();
		this.cacheMainTeachers = new HashMap<String, String>();
		this.cacheAssistants = new HashMap<String, String>();
	}

	private void initCacheMap() {
		if (schedules != null && !schedules.isEmpty()) {
			for (ScheduleRecord rec : schedules) {
				this.cachePlaces.put(rec.getPlaceId(), rec.getPlaceName());
				this.cacheMainTeachers.put(rec.getMainTeacherId(),
						rec.getMainTeacherName());
				this.cacheAssistants.put(rec.getAssistantId(), rec.getAssistantName());
			}
		}
	}

	/**
	 * 获取班级的所有场地
	 * 
	 * @return
	 */
	public String getPlaces() {
		if (this.cachePlaces.isEmpty()) {
			initCacheMap();
		}
		if (cachePlaces.isEmpty()) {
			return "";

		}
		return JoinUtils.join(this.cachePlaces.values());
	}

	/**
	 * 获取班级的所有老师
	 * 
	 * @return
	 */
	public String getMainTeachers() {
		if (this.cacheMainTeachers.isEmpty()) {
			initCacheMap();
		}
		if (this.cacheMainTeachers.isEmpty()) {
			return "";
		}
		return JoinUtils.join(this.cacheMainTeachers.values());
	}

	/**
	 * 获取班级的所有助教
	 * 
	 * @return
	 */
	public String getAssistants() {
		if (this.cacheAssistants.isEmpty()) {
			initCacheMap();
		}
		if (this.cacheAssistants.isEmpty()) {
			return "";
		}
		return JoinUtils.join(this.cacheAssistants.values());
	}

	public String getProducts() {
		return JoinUtils.join(this.products);
	}

	public void setProducts(List<String> products) {
		this.products = products;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name == null ? "" : name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getState() {
		return state == null ? "" : state;
	}

	public void setState(String state) {
		this.state = state;
	}

	public String getOfficer() {
		return officer == null ? "" : officer;
	}

	public void setOfficer(String officer) {
		this.officer = officer;
	}

	public void setSchedules(List<ScheduleRecord> schedules) {
		this.schedules = schedules;
	}

	public String getType() {
		return type == null ? "" : type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getStartTime() {
		return startTime == null ? "" : startTime.substring(0,10);
	}

	public void setStartTime(String startTime) {
		this.startTime = startTime;
	}

	public String getEndTime() {
		return endTime == null ? "" : endTime.substring(0,10);
	}

	public void setEndTime(String endTime) {
		this.endTime = endTime;
	}

}
